<template>
    <div id="tr_bg_re">
        <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
            <div v-for="(item,index) in list" :key="index" class="van-cell flexbox spacebetween" style="background: transparent;">
                <div>
                    <p>{{item.twoemail}}</p>
                    <p class="van-cell__label">{{item.tr_type == 1 ? '转证券' : item.tr_type == 2 ? '转美金余额' : '证券转美金'}}</p>
                    <p>{{item.p_name}}</p>
                </div>
                <div class="text-right">
                    <p class="van-cell__value">{{item.tr_create_time}}</p>
                    <p class="colorO bolds">{{item.zz_type}} {{item.tr_type == 1 ? item.tr_market_value : item.tr_type == 2 ? item.tr_dollar : item.tr_market_value}}</p>
                </div>
            </div>
        </van-list>
    </div>
</template>
<script>

    import '@/assets/css/main.css'
    export default {
        data(){
            return{
                list: [],
                loading: false,
                finished: false,
                page: 0,
            }
        },
        methods: {
            onLoad() {

                var _this = this;

                this.$httpGet('/api/index/Personal_center/getUserRecord',{
                    'page': ++this.page,
                    'u_id': window.localStorage.u_id,
                    'type': 1,
                }).then(response => {
                    
                    if(response.code == 200){

                        let re = response.msg.data;
                        if (re.length !== 0) {
                            
                            //新增数据拼接在后面
                            _this.list = _this.list.concat(response.msg.data);

                            for(var i=0;i<_this.list.length;i++){

                                if(_this.list[i].tr_enter_uid == window.localStorage.u_id){  //被转账人id   +

                                    _this.list[i].zz_type = '+';

                                }else if(response.msg.data[i].tr_out_uid == window.localStorage.u_id){  //自己id  -
                                    
                                    _this.list[i].zz_type = '-';

                                }
                                
                            }
                            console.log(_this.list);
                        }
                    
                        // 加载状态结束
                        this.loading = false;

                        // 数据全部加载完成
                        if (this.list.length >= response.msg.total) {
                            this.finished = true;
                        }

                    }else{
                        this.$toast(response.msg);
                    }

                });
            },
        },
        mounted(){
            
        },
    }
</script>
<style>
    #tr_bg_re{
        /* background: url('../../assets/images/bg_r.png');
        background-size: 100% 100%;
        min-height: 100vh; */
    }
</style>